package com.shiikong_memory.yez.VirginGenerator;

import kotlinx.serialization.json.JsonObject;
import love.forte.simbot.component.kook.KookChatChannel;
import love.forte.simbot.component.kook.event.KookChannelMessageEvent;
import love.forte.simbot.kook.api.message.SendChannelMessageApi;
import love.forte.simbot.quantcat.common.annotations.ContentTrim;
import love.forte.simbot.quantcat.common.annotations.Listener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.util.concurrent.CompletableFuture;

@Component
public class SaintGeneratedListener {
    @Listener
    @ContentTrim
    public CompletableFuture<?> handle(KookChannelMessageEvent event){
        String[] split = event.getSourceEvent().getContent().split("圣女生成:");
        if (split.length == 2){
            split[1] = split[1].replaceAll(" ","");
            String cardJson = SaintGeneratedModule.getCardJson(SaintGeneratedModule.create(split[1]));
            KookChatChannel content = event.getContent();
            return event.getContent().sendAsync(SendChannelMessageApi.create(10,event.getSourceEvent().getTargetId(), cardJson));
        }
        return null;
    }
}
